package com.inossem.warehousestorage_inossem.dialog;

import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.Point;
import android.text.InputType;
import android.text.TextUtils;
import android.view.Display;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

import com.inossem.utils.base.CameraUtils;
import com.inossem.utils.base.Utils;
import com.inossem.utils.dialog.BaseDialog;
import com.inossem.utils.listener.NoDoubleClickListener;
import com.inossem.utils.log.LogUtils;
import com.inossem.warehousestorage_inossem.R;
import com.inossem.warehousestorage_inossem.activity.base.BaseActivity;
import com.inossem.warehousestorage_inossem.adapter.OverviewAdapter;
import com.inossem.warehousestorage_inossem.adapter.allocation.AllocationCreatDocumentFtyAdapter;
import com.inossem.warehousestorage_inossem.adapter.analysis.WorkStatisticsBlockListAdapter;
import com.inossem.warehousestorage_inossem.adapter.analysis.WorkStatisticsFactoryListAdapter;
import com.inossem.warehousestorage_inossem.adapter.analysis.WorkStatisticsInventoryAddressListAdapter;
import com.inossem.warehousestorage_inossem.adapter.analysis.WorkStatisticsPersonListAdapter;
import com.inossem.warehousestorage_inossem.adapter.changeStorage.ChangeMoveTypeListAdapter;
import com.inossem.warehousestorage_inossem.adapter.changeStorage.ChangeStorageFactoryListAdapter;
import com.inossem.warehousestorage_inossem.adapter.changeStorage.ChangeStorageInventoryAddressListAdapter;
import com.inossem.warehousestorage_inossem.adapter.changeStorage.chuangyou.CYChangeStorageLocationListAdapter;
import com.inossem.warehousestorage_inossem.adapter.common.SelectListAdapter;
import com.inossem.warehousestorage_inossem.adapter.inStorage.AllocatingSelectListAdapter;
import com.inossem.warehousestorage_inossem.adapter.inStorage.FreeInventoryAddressListAdapter;
import com.inossem.warehousestorage_inossem.adapter.inStorage.FreeSelectListAdapter;
import com.inossem.warehousestorage_inossem.adapter.inStorage.OtherFactoryListAdapter;
import com.inossem.warehousestorage_inossem.adapter.inStorage.OtherInStorageReasonListAdapter;
import com.inossem.warehousestorage_inossem.adapter.inStorage.OtherInventoryAddressListAdapter;
import com.inossem.warehousestorage_inossem.adapter.inStorage.OtherMoveListAdapter;
import com.inossem.warehousestorage_inossem.adapter.inStorage.OtherSelectListAdapter;
import com.inossem.warehousestorage_inossem.adapter.inStorage.ReasonListAdapter;
import com.inossem.warehousestorage_inossem.adapter.inStorage.ReceiveInventoryAddressListAdapter;
import com.inossem.warehousestorage_inossem.adapter.inStorage.ReceiveSelectListAdapter;
import com.inossem.warehousestorage_inossem.adapter.inStorage.RoleListAdapter;
import com.inossem.warehousestorage_inossem.adapter.inStorage.TenderInventoryAddressListAdapter;
import com.inossem.warehousestorage_inossem.adapter.inStorage.TenderSelectListAdapter;
import com.inossem.warehousestorage_inossem.adapter.inStorage.UserGroupListAdapter;
import com.inossem.warehousestorage_inossem.adapter.outStorage.OtherOutStorageInventoryAddressListAdapter;
import com.inossem.warehousestorage_inossem.adapter.outStorage.OtherOutStorageMoveListAdapter;
import com.inossem.warehousestorage_inossem.adapter.outStorage.OtherOutStorageReceivingPartyListAdapter;
import com.inossem.warehousestorage_inossem.adapter.outStorage.OutStorageAddBatchAdapter;
import com.inossem.warehousestorage_inossem.adapter.outStorage.OutStorageOtherFactoryListAdapter;
import com.inossem.warehousestorage_inossem.adapter.outStorage.PickingOutStorageAddBatchAdapter;
import com.inossem.warehousestorage_inossem.adapter.query.QueryAreaListAdapter;
import com.inossem.warehousestorage_inossem.adapter.query.QueryBatchNumberListAdapter;
import com.inossem.warehousestorage_inossem.adapter.query.QueryOutStorageInventoryAddressListAdapter;
import com.inossem.warehousestorage_inossem.adapter.query.QueryWarehouseListAdapter;
import com.inossem.warehousestorage_inossem.adapter.receive.DisposeWayListAdapter;
import com.inossem.warehousestorage_inossem.adapter.refundStorage.RefundStoragePickingBatchListAdapter;
import com.inossem.warehousestorage_inossem.adapter.refundStorage.RefundStoragePickingRoleListAdapter;
import com.inossem.warehousestorage_inossem.adapter.refundStorage.RefundStoragePickingUserGroupListAdapter;
import com.inossem.warehousestorage_inossem.adapter.refundStorage.RefundStorageSaleBatchListAdapter;
import com.inossem.warehousestorage_inossem.adapter.refundStorage.RefundStorageSaltSelectListAdapter;
import com.inossem.warehousestorage_inossem.adapter.storage.StorageMaterielFactoryListAdapter;
import com.inossem.warehousestorage_inossem.adapter.storage.StorageMaterielInventoryAddressListAdapter;
import com.inossem.warehousestorage_inossem.adapter.storage.StoragePositionListAdapter;
import com.inossem.warehousestorage_inossem.bean.allocation.AllocationOutStorageBaseInfoBean;
import com.inossem.warehousestorage_inossem.bean.analysis.AnalysisWorkStatisticsGetPersonBean;
import com.inossem.warehousestorage_inossem.bean.analysis.AnalysisWorkStatisticsIndexBean;
import com.inossem.warehousestorage_inossem.bean.changeStorage.ChangeStorageManageBean;
import com.inossem.warehousestorage_inossem.bean.changeStorage.chuangyou.CYChangeStorageLocationBean;
import com.inossem.warehousestorage_inossem.bean.common.GetOperatorGroupBean;
import com.inossem.warehousestorage_inossem.bean.common.GetRoleBean;
import com.inossem.warehousestorage_inossem.bean.common.KeyValueBean;
import com.inossem.warehousestorage_inossem.bean.inStorage.InStorageAllocatingOverviewBean;
import com.inossem.warehousestorage_inossem.bean.inStorage.InStorageFreeBaseInfoBean;
import com.inossem.warehousestorage_inossem.bean.inStorage.InStorageFreeOverviewBean;
import com.inossem.warehousestorage_inossem.bean.inStorage.InStorageOtherIndexBean;
import com.inossem.warehousestorage_inossem.bean.inStorage.InStorageOtherOverviewBean;
import com.inossem.warehousestorage_inossem.bean.inStorage.InStorageReceiveAddOperatorUserGroupBean;
import com.inossem.warehousestorage_inossem.bean.inStorage.InStorageReceiveOverviewBean;
import com.inossem.warehousestorage_inossem.bean.inStorage.InStorageRoleBean;
import com.inossem.warehousestorage_inossem.bean.inStorage.InStorageTenderBaseInfoBean;
import com.inossem.warehousestorage_inossem.bean.outStorage.BatchBean;
import com.inossem.warehousestorage_inossem.bean.outStorage.OutStorageCalculatorBean;
import com.inossem.warehousestorage_inossem.bean.outStorage.OutStorageOtherIndexBean;
import com.inossem.warehousestorage_inossem.bean.outStorage.OutStoragePickingBatchListBean;
import com.inossem.warehousestorage_inossem.bean.query.QueryMaterielDetailBean;
import com.inossem.warehousestorage_inossem.bean.query.QueryOutStorageInventoryAddressBean;
import com.inossem.warehousestorage_inossem.bean.query.QueryWarehouseBean;
import com.inossem.warehousestorage_inossem.bean.receive.ReceiveReceiveItemBean;
import com.inossem.warehousestorage_inossem.bean.refundStorage.BatchSpecListBean;
import com.inossem.warehousestorage_inossem.bean.refundStorage.RefundStorageAddOperatorUserGroupBean;
import com.inossem.warehousestorage_inossem.bean.refundStorage.RefundStorageNewBatchBean;
import com.inossem.warehousestorage_inossem.bean.refundStorage.RefundStoragePickingOverviewBean;
import com.inossem.warehousestorage_inossem.bean.refundStorage.RefundStorageRoleBean;
import com.inossem.warehousestorage_inossem.bean.refundStorage.RefundStorageSaleBatchListBean;
import com.inossem.warehousestorage_inossem.bean.storage.StorageManageMaterielIndexBean;
import com.inossem.warehousestorage_inossem.bean.storage.StorageManagePosiBean;
import com.inossem.warehousestorage_inossem.listener.GetOperatorGroupListener;
import com.inossem.warehousestorage_inossem.listener.OutStorageAddBatchListener;
import com.inossem.warehousestorage_inossem.manage.ImageManage;
import com.inossem.warehousestorage_inossem.utils.InStorageUtils;
import com.inossem.warehousestorage_inossem.utils.OutStorageUtils;
import com.inossem.warehousestorage_inossem.utils.RefundStorageUtils;
import com.zhy.android.percent.support.PercentLinearLayout;

import java.util.ArrayList;
import java.util.List;


public class DialogUtils {

    public static abstract class ConfirmDialogListener {
        public abstract void onConfirm(Dialog dialog);

        public void onCancel() {
        }
    }

    public static abstract class EditTextDialogListener {
        public abstract void onConfirm(Dialog dialog, String result);

        public void onCancel() {
        }
    }

    public static abstract class DisposeWayListener {
        public abstract void onSelect(Dialog dialog, String description, String value);
    }

    public static abstract class SelectListener {
        public abstract void onSelect(Dialog dialog, String text, String value);
    }

    public static abstract class DeleteListener {
        public abstract void onDelect(Dialog dialog);
    }

    public static abstract class ReceiveInventoryAddressListener {
        public abstract void onSelect(Dialog dialog, String inventoryAddressValue, String inventoryAddressCode, String factoryValue, String factoryCode);
    }

    public static abstract class FreeInventoryAddressListener {
        public abstract void onSelect(Dialog dialog, String inventoryAddressValue, String inventoryAddressCode, String factoryValue, String factoryCode, String locationId);
    }

    public static abstract class TenderInventoryAddressListener {
        public abstract void onSelect(Dialog dialog, String inventoryAddressValue, String inventoryAddressCode, String factoryValue, String factoryCode, String locationId);
    }

    public static abstract class FactoryListener {
        public abstract void onSelect(Dialog dialog, String text, String value, List<InStorageOtherIndexBean.OtherBean.FtyListBean.LocationAryBean> inventoryAddressList);
    }

    public static abstract class OutStorageFactoryListener {
        public abstract void onSelect(Dialog dialog, String text, String value, List<OutStorageOtherIndexBean.BodyBean.FtyListBean.LocationAryBean> inventoryAddressList);
    }

    public static abstract class MoveListener {
        public abstract void onSelect(Dialog dialog, String text, String specialInventory, String moveTypeDescription, String id, List<InStorageOtherIndexBean.OtherBean.MoveListBean.ReasonListBean> reasonList);
    }

    public static abstract class MoveOutStorageListener {
        public abstract void onSelect(Dialog dialog, String id, String code, String name, String specialInventory);
    }

    public static abstract class AddBatchListener {
        public abstract void onSelect(Dialog dialog, OutStoragePickingBatchListBean.DataBean.BatchListBean bean);
    }

    public static abstract class AddBatchListenerNew {
        public abstract void onSelect(Dialog dialog, BatchBean.BatchInfoBean bean);
    }

    public static class LoadingListener {
        public void onCancel() {
        }
    }

    public static abstract class ChangeStorageFactoryListener {
        public abstract void onSelect(Dialog dialog, String text, String value, String fty_id, List<ChangeStorageManageBean.DataBean.FtyListBean.LocationAryBean> inventoryAddressList);
    }

    public static abstract class ChangeStorageInventoryAddressListener {
        public abstract void onSelect(Dialog dialog, String text, String value, String id, String warehouseNumber);
    }

    public static abstract class ChangeStorageMoveTypeListener {
        public abstract void onSelect(Dialog dialog, String moveType, String moveTypeDescription, String move_id, String specialInventory, String businessType);
    }

    public static abstract class WarehouseListener {
        public abstract void onSelect(Dialog dialog, String warehouseNumber, String warehouseDescription, List<QueryWarehouseBean.DataBean.WarehouseListBean.AreaListBean> areaList);
    }

    public static abstract class AreaListener {
        public abstract void onSelect(Dialog dialog, String areaNumber, String areaDescription);
    }

    public static abstract class BatchNumberListener {
        public abstract void onSelect(Dialog dialog, QueryMaterielDetailBean.DataBean.BatchListBean batchItem);
    }

    public static abstract class QueryOutStorageListener {
        public abstract void onSelect(Dialog dialog, String text, String value);
    }

    public static abstract class RoleListener {
        public abstract void onSelect(Dialog dialog, String roleName, String roleCode);
    }

    public static abstract class RefundStoragePickingBatchNumberListener {
        public abstract void onSelect(Dialog dialog, String batchNumber, List<RefundStoragePickingOverviewBean.OutputInfoBodyBean.ItemListBean.BatchListBean.BatchSpecListBean> batchInfoList);
    }

    public static abstract class RefundStorageSaleBatchNumberListener {
        public abstract void onSelect(Dialog dialog, String batchNumber, List<RefundStorageSaleBatchListBean.SaleBatchBodyBean.BatchSpecListBean> batchInfoList);

        public abstract void onNewBatch();
    }

    public static abstract class RefundStorageSaleNewBatchNumberListener {
        public abstract void onNewBatch(List<BatchSpecListBean> list);
    }

    public static abstract class AnalysisWorkStatisticsListener {
        public abstract void onSelect(Dialog dialog, String text, String value);
    }

    public static abstract class StoragePositionListener {
        public abstract void onSelect(Dialog dialog, String id, String code, String name, String factoryId, String inventoryId);
    }

    public static abstract class StorageMaterielFactoryListener {
        public abstract void onSelect(Dialog dialog, String id, String code, String name, List<StorageManageMaterielIndexBean.BodyBean.LocationAryBean> inventoryAddressList);
    }

    public static abstract class StorageMaterielInventoryAddressListener {
        public abstract void onSelect(Dialog dialog, String inventoryAddressId, String inventoryAddressCode, String inventoryAddressName, String warehouseId);
    }

    public static abstract class CYChangStorageSelectLocationListener {
        public abstract void onSelect(Dialog dialog, String code, String name , String id);
    }

    public static abstract class AllocationCreatDocumentFtyListener {
        public abstract void onSelect(Dialog dialog, String id, String code, String name);
    }

    //获取确认弹出框
    public static Dialog getConfirmDialog(final Context context, final String promptInfo, ConfirmDialogListener listener) {
        BaseDialog baseDialog = BaseDialog.createDialog(context, R.layout.dialog_confirm, (Context con, View view, Dialog dialog) -> {
                    TextView prompt = (TextView) view.findViewById(R.id.prompt);
                    prompt.setText(promptInfo);
                    Button cancel = (Button) view.findViewById(R.id.cancel);
                    Button confirm = (Button) view.findViewById(R.id.confirm);
                    cancel.setOnClickListener(new NoDoubleClickListener() {
                        @Override
                        public void onNoDoubleClick(View v) {
                            dialog.cancel();
                        }
                    });
                    confirm.setOnClickListener(new NoDoubleClickListener() {
                        @Override
                        public void onNoDoubleClick(View v) {
                            listener.onConfirm(dialog);
                        }
                    });
                }
        );
        return baseDialog;
    }

    public static Dialog getDisposeWayDialog(final Context context, final List<ReceiveReceiveItemBean.DataBean.DisposeWayListBean> list, DisposeWayListener disposeWayListener) {
        BaseDialog baseDialog = BaseDialog.createDialog(context, R.layout.dialog_dispose_way, null, WindowManager.LayoutParams.WRAP_CONTENT, (Context con, View view, Dialog dialog) -> {
                    ListView disposeWayList = (ListView) view.findViewById(R.id.disposeWayList);
                    DisposeWayListAdapter adapter = new DisposeWayListAdapter(context, list, new DisposeWayListAdapter.DisposeWayListAdapterListener() {
                        @Override
                        public void onSelect(String description, String value) {
                            dialog.cancel();
                            disposeWayListener.onSelect(dialog, description, value);
                        }
                    });
                    disposeWayList.setAdapter(adapter);
                }
        );
        return baseDialog;
    }

    //计算器dialog
    public static Dialog getCalculatorDialog(final Context context, OutStorageCalculatorBean bean) {
        BaseDialog baseDialog = BaseDialog.createDialog(context, R.layout.dialog_calculators, null, WindowManager.LayoutParams.WRAP_CONTENT, (Context con, View view, Dialog dialog) -> {
                    PercentLinearLayout batch = (PercentLinearLayout) view.findViewById(R.id.batchLayout);
                    TextView constantName = (TextView) view.findViewById(R.id.constantName);
                    TextView constantValue = (TextView) view.findViewById(R.id.constantValue);
                    Button calculate = (Button) view.findViewById(R.id.calculate);
                    Button cancel = (Button) view.findViewById(R.id.cancel);
                    TextView result = (TextView) view.findViewById(R.id.result);
                    constantName.setText(bean.getData().getCalculator().getConstantName());
                    constantValue.setText(bean.getData().getCalculator().getConstantValue());
                    List<OutStorageCalculatorBean.DataBean.CalculatorBean.PropertyListBean> list = bean.getData().getCalculator().getPropertyList();
                    for (int i = 0; i < list.size(); i++) {
                        OutStorageUtils.createEditText(context, batch, list.get(i).getName(), list.get(i).getUnit(), i + 1);
                    }
                    cancel.setOnClickListener(new NoDoubleClickListener() {
                        @Override
                        public void onNoDoubleClick(View v) {
                            dialog.cancel();
                        }
                    });
                    calculate.setOnClickListener(new NoDoubleClickListener() {
                        @Override
                        public void onNoDoubleClick(View v) {
                            String resultText = OutStorageUtils.check(context, list, view);
                            if (resultText == null) {
                                result.setText(OutStorageUtils.calculate(bean.getData().getCalculator().getConstantValue(), list, view));
                                Utils.saveMessageToClipboard(context, result.getText().toString());
                                Utils.closeSoftKeyboard(context, view);
                                Toast.makeText(context, "计算结果已保存到剪切板", Toast.LENGTH_LONG).show();
                            } else {
                                Toast.makeText(context, resultText, Toast.LENGTH_SHORT).show();
                            }
                        }
                    });
                }
        );
        return baseDialog;
    }

    public static Dialog getReceiveSelectDialog(final Context context, final List<InStorageReceiveOverviewBean.DataBean.ReceiveInStorageListBean.BatchBean.SelectBean> selectList, SelectListener selectListener) {
        BaseDialog baseDialog = BaseDialog.createDialog(context, R.layout.dialog_dispose_way, null, WindowManager.LayoutParams.WRAP_CONTENT, (Context con, View view, Dialog dialog) -> {
                    ListView disposeWayList = (ListView) view.findViewById(R.id.disposeWayList);
                    ReceiveSelectListAdapter adapter = new ReceiveSelectListAdapter(context, selectList, new ReceiveSelectListAdapter.KeyValueListAdapterListener() {
                        @Override
                        public void onSelect(String text, String value) {
                            dialog.cancel();
                            selectListener.onSelect(dialog, text, value);
                        }
                    });
                    disposeWayList.setAdapter(adapter);
                }
        );
        return baseDialog;
    }

    //获取调拨入库下拉选择框
    public static Dialog getAllocatingSelectDialog(final Context context, final List<InStorageAllocatingOverviewBean.ReceiveInAllocatingStorageListBean.StockInputItemBean.BatchSpecListBean.InfoBean> selectList, SelectListener selectListener) {
        BaseDialog baseDialog = BaseDialog.createDialog(context, R.layout.dialog_dispose_way, null, WindowManager.LayoutParams.WRAP_CONTENT, (Context con, View view, Dialog dialog) -> {
                    ListView disposeWayList = (ListView) view.findViewById(R.id.disposeWayList);
                    AllocatingSelectListAdapter adapter = new AllocatingSelectListAdapter(context, selectList, new ReceiveSelectListAdapter.KeyValueListAdapterListener() {
                        @Override
                        public void onSelect(String text, String value) {
                            dialog.cancel();
                            selectListener.onSelect(dialog, text, value);
                        }
                    });
                    disposeWayList.setAdapter(adapter);
                }
        );
        return baseDialog;
    }

    //获取免检入库下拉选择框
    public static Dialog getFreeSelectDialog(final Context context, final List<InStorageFreeOverviewBean.OverviewBean.PurchaseOrderItemListBean.BatchSpecListBean.InfoBean> selectList, SelectListener selectListener) {
        BaseDialog baseDialog = BaseDialog.createDialog(context, R.layout.dialog_dispose_way, null, WindowManager.LayoutParams.WRAP_CONTENT, (Context con, View view, Dialog dialog) -> {
                    ListView disposeWayList = (ListView) view.findViewById(R.id.disposeWayList);
                    FreeSelectListAdapter adapter = new FreeSelectListAdapter(context, selectList, new FreeSelectListAdapter.KeyValueListAdapterListener() {
                        @Override
                        public void onSelect(String text, String value) {
                            dialog.cancel();
                            selectListener.onSelect(dialog, text, value);
                        }
                    });
                    disposeWayList.setAdapter(adapter);
                }
        );
        return baseDialog;
    }

    //获取销售出库下拉选择框
    public static Dialog getNewBatchSelectDialog(final Context context, final List<BatchSpecListBean.InfoBean> selectList, SelectListener selectListener) {
        BaseDialog baseDialog = BaseDialog.createDialog(context, R.layout.dialog_dispose_way, null, WindowManager.LayoutParams.WRAP_CONTENT, (Context con, View view, Dialog dialog) -> {
                    ListView disposeWayList = (ListView) view.findViewById(R.id.disposeWayList);
                    RefundStorageSaltSelectListAdapter adapter = new RefundStorageSaltSelectListAdapter(context, selectList, new FreeSelectListAdapter.KeyValueListAdapterListener() {
                        @Override
                        public void onSelect(String text, String value) {
                            dialog.cancel();
                            selectListener.onSelect(dialog, text, value);
                        }
                    });
                    disposeWayList.setAdapter(adapter);
                }
        );
        return baseDialog;
    }

    //获取招采入库下拉选择框
    public static Dialog getTenderSelectDialog(final Context context, final List<InStorageFreeOverviewBean.OverviewBean.PurchaseOrderItemListBean.BatchSpecListBean.InfoBean> selectList, SelectListener selectListener) {
        BaseDialog baseDialog = BaseDialog.createDialog(context, R.layout.dialog_dispose_way, null, WindowManager.LayoutParams.WRAP_CONTENT, (Context con, View view, Dialog dialog) -> {
                    ListView disposeWayList = (ListView) view.findViewById(R.id.disposeWayList);
                    TenderSelectListAdapter adapter = new TenderSelectListAdapter(context, selectList, new TenderSelectListAdapter.KeyValueListAdapterListener() {
                        @Override
                        public void onSelect(String text, String value) {
                            dialog.cancel();
                            selectListener.onSelect(dialog, text, value);
                        }
                    });
                    disposeWayList.setAdapter(adapter);
                }
        );
        return baseDialog;
    }

    public static Dialog getOtherSelectDialog(final Context context, final List<InStorageOtherOverviewBean.MaterielListBean.BatchSpecListBean.InfoBean> selectList, SelectListener selectListener) {
        BaseDialog baseDialog = BaseDialog.createDialog(context, R.layout.dialog_dispose_way, null, WindowManager.LayoutParams.WRAP_CONTENT, (Context con, View view, Dialog dialog) -> {
                    ListView disposeWayList = (ListView) view.findViewById(R.id.disposeWayList);
                    OtherSelectListAdapter adapter = new OtherSelectListAdapter(context, selectList, new OtherSelectListAdapter.KeyValueListAdapterListener() {
                        @Override
                        public void onSelect(String text, String value) {
                            dialog.cancel();
                            selectListener.onSelect(dialog, text, value);
                        }
                    });
                    disposeWayList.setAdapter(adapter);
                }
        );
        return baseDialog;
    }

    public static Dialog getSelectReasonDialog(final Context context, final List<InStorageFreeBaseInfoBean.BaseInfoBean.UnCheckReasonListBean> reasonList, SelectListener selectListener) {
        BaseDialog baseDialog = BaseDialog.createDialog(context, R.layout.dialog_dispose_way, null, WindowManager.LayoutParams.WRAP_CONTENT, (Context con, View view, Dialog dialog) -> {
                    ListView disposeWayList = (ListView) view.findViewById(R.id.disposeWayList);
                    ReasonListAdapter adapter = new ReasonListAdapter(context, reasonList, new ReasonListAdapter.KeyValueListAdapterListener() {
                        @Override
                        public void onSelect(String text, String value) {
                            dialog.cancel();
                            selectListener.onSelect(dialog, text, value);
                        }
                    });
                    disposeWayList.setAdapter(adapter);
                }
        );
        return baseDialog;
    }

    public static Dialog getReceiveInventoryAddressDialog(final Context context, final List<InStorageReceiveOverviewBean.DataBean.InventoryAddressListBean> list, ReceiveInventoryAddressListener inventoryAddressListener) {
        BaseDialog baseDialog = BaseDialog.createDialog(context, R.layout.dialog_dispose_way, null, WindowManager.LayoutParams.WRAP_CONTENT, (Context con, View view, Dialog dialog) -> {
                    ListView listView = (ListView) view.findViewById(R.id.disposeWayList);
                    ReceiveInventoryAddressListAdapter adapter = new ReceiveInventoryAddressListAdapter(context, list, new ReceiveInventoryAddressListAdapter.InventoryAddressListAdapterListener() {
                        @Override
                        public void onSelect(String inventoryAddressValue, String inventoryAddressCode, String factoryValue, String factoryCode) {
                            dialog.cancel();
                            inventoryAddressListener.onSelect(dialog, inventoryAddressValue, inventoryAddressCode, factoryValue, factoryCode);
                        }
                    });
                    listView.setAdapter(adapter);
                }
        );
        return baseDialog;
    }


    //获取免检入库库存地点弹出框
    public static Dialog getFreeInventoryAddressDialog(final Context context, final List<InStorageFreeBaseInfoBean.BaseInfoBean.FtyListBean.LocationAryBean> list, FreeInventoryAddressListener inventoryAddressListener) {
        BaseDialog baseDialog = BaseDialog.createDialog(context, R.layout.dialog_dispose_way, null, WindowManager.LayoutParams.WRAP_CONTENT, (Context con, View view, Dialog dialog) -> {
                    ListView listView = (ListView) view.findViewById(R.id.disposeWayList);
                    FreeInventoryAddressListAdapter adapter = new FreeInventoryAddressListAdapter(context, list, new FreeInventoryAddressListAdapter.InventoryAddressListAdapterListener() {
                        @Override
                        public void onSelect(String inventoryAddressValue, String inventoryAddressCode, String factoryValue, String factoryCode, String locationId) {
                            dialog.cancel();
                            inventoryAddressListener.onSelect(dialog, inventoryAddressValue, inventoryAddressCode, factoryValue, factoryCode, locationId);
                        }
                    });
                    listView.setAdapter(adapter);
                }
        );
        return baseDialog;
    }

    //获取招采入库库存地点弹出框
    public static Dialog getTenderInventoryAddressDialog(final Context context, final List<InStorageTenderBaseInfoBean.FtyBean.LocationAryBean> list, TenderInventoryAddressListener inventoryAddressListener) {
        BaseDialog baseDialog = BaseDialog.createDialog(context, R.layout.dialog_dispose_way, null, WindowManager.LayoutParams.WRAP_CONTENT, (Context con, View view, Dialog dialog) -> {
                    ListView listView = (ListView) view.findViewById(R.id.disposeWayList);
                    TenderInventoryAddressListAdapter adapter = new TenderInventoryAddressListAdapter(context, list, new TenderInventoryAddressListAdapter.InventoryAddressListAdapterListener() {
                        @Override
                        public void onSelect(String inventoryAddressValue, String inventoryAddressCode, String factoryValue, String factoryCode, String locationId) {
                            dialog.cancel();
                            inventoryAddressListener.onSelect(dialog, inventoryAddressValue, inventoryAddressCode, factoryValue, factoryCode, locationId);
                        }
                    });
                    listView.setAdapter(adapter);
                }
        );
        return baseDialog;
    }

    public static Dialog getSelectDialog(final Context context, final List<KeyValueBean.ListBean> list, SelectListener selectListener) {
        BaseDialog baseDialog = BaseDialog.createDialog(context, R.layout.dialog_select, null, WindowManager.LayoutParams.WRAP_CONTENT, (Context con, View view, Dialog dialog) -> {
                    ListView disposeWayList = (ListView) view.findViewById(R.id.list);
                    SelectListAdapter adapter = new SelectListAdapter(context, list, new SelectListAdapter.KeyValueListAdapterListener() {
                        @Override
                        public void onSelect(String value, String code) {
                            dialog.cancel();
                            selectListener.onSelect(dialog, value, code);
                        }
                    });
                    disposeWayList.setAdapter(adapter);
                }
        );
        return baseDialog;
    }

    //其他入库获取工厂
    public static Dialog getFactoryDialog(final Context context, final List<InStorageOtherIndexBean.OtherBean.FtyListBean> list, FactoryListener listener) {
        BaseDialog baseDialog = BaseDialog.createDialog(context, R.layout.dialog_dispose_way, null, WindowManager.LayoutParams.WRAP_CONTENT, (Context con, View view, Dialog dialog) -> {
                    ListView disposeWayList = (ListView) view.findViewById(R.id.disposeWayList);
                    OtherFactoryListAdapter adapter = new OtherFactoryListAdapter(context, list, new OtherFactoryListAdapter.FactoryListAdapterListener() {
                        @Override
                        public void onSelect(String description, String value, List<InStorageOtherIndexBean.OtherBean.FtyListBean.LocationAryBean> inventoryAddressList) {
                            dialog.cancel();
                            listener.onSelect(dialog, description, value, inventoryAddressList);
                        }
                    });
                    disposeWayList.setAdapter(adapter);
                }
        );
        return baseDialog;
    }

    //其他出库获取工厂
    public static Dialog getOutStorageFactoryDialog(final Context context, final List<OutStorageOtherIndexBean.BodyBean.FtyListBean> list, OutStorageFactoryListener listener) {
        BaseDialog baseDialog = BaseDialog.createDialog(context, R.layout.dialog_dispose_way, null, WindowManager.LayoutParams.WRAP_CONTENT, (Context con, View view, Dialog dialog) -> {
                    ListView disposeWayList = (ListView) view.findViewById(R.id.disposeWayList);
                    OutStorageOtherFactoryListAdapter adapter = new OutStorageOtherFactoryListAdapter(context, list, new OutStorageOtherFactoryListAdapter.FactoryListAdapterListener() {
                        @Override
                        public void onSelect(String description, String value, List<OutStorageOtherIndexBean.BodyBean.FtyListBean.LocationAryBean> inventoryAddressList) {
                            dialog.cancel();
                            listener.onSelect(dialog, description, value, inventoryAddressList);
                        }
                    });
                    disposeWayList.setAdapter(adapter);
                }
        );
        return baseDialog;
    }

    //转储管理获取工厂
    public static Dialog getChangeStorageFactoryDialog(final Context context, final List<ChangeStorageManageBean.DataBean.FtyListBean> list, ChangeStorageFactoryListener listener) {
//        BaseDialog baseDialog = BaseDialog.createDialog(context, R.layout.dialog_dispose_way, null, WindowManager.LayoutParams.WRAP_CONTENT, (Context con, View view, Dialog dialog) -> {
//                    ListView disposeWayList = (ListView) view.findViewById(R.id.disposeWayList);
//                    ChangeStorageFactoryListAdapter adapter = new ChangeStorageFactoryListAdapter(context, list, new ChangeStorageFactoryListAdapter.ChangeStorageFactoryListAdapterListener() {
//                        @Override
//                        public void onSelect(String description, String value, List<ChangeStorageManageBean.DataBean.InventoryAddressListBean> inventoryAddressList) {
//                            dialog.cancel();
//                            listener.onSelect(dialog, description, value, inventoryAddressList);
//                        }
//                    });
//                    disposeWayList.setAdapter(adapter);
//                }
//        );
        return getChangeStorageFactoryDialogNew(context, list, false, listener);
    }

    //转储管理获取工厂
    public static Dialog getChangeStorageFactoryDialogNew(final Context context, final List<ChangeStorageManageBean.DataBean.FtyListBean> list, boolean withFilter, ChangeStorageFactoryListener listener) {
        BaseDialog baseDialog = BaseDialog.createDialog(context, R.layout.dialog_selece_factory_filter, null, WindowManager.LayoutParams.WRAP_CONTENT, (Context con, View view, Dialog dialog) -> {
                    ListView listview = (ListView) view.findViewById(R.id.listview);
                    ChangeStorageFactoryListAdapter.ChangeStorageFactoryListAdapterListener adapterlistener = new ChangeStorageFactoryListAdapter.ChangeStorageFactoryListAdapterListener() {
                        @Override
                        public void onSelect(String description, String value, String fty_id, List<ChangeStorageManageBean.DataBean.FtyListBean.LocationAryBean> inventoryAddressList) {
                            dialog.cancel();
                            listener.onSelect(dialog, description, value, fty_id, inventoryAddressList);
                        }
                    };
                    listview.setAdapter(new ChangeStorageFactoryListAdapter(context, list, adapterlistener));
                    EditText condition = (EditText) view.findViewById(R.id.condition);
                    ImageView search = (ImageView) view.findViewById(R.id.search);
                    if (withFilter) {
                        search.setOnClickListener(new NoDoubleClickListener() {
                            @Override
                            public void onNoDoubleClick(View v) {
                                String conditionStr = condition.getText().toString();
                                List<ChangeStorageManageBean.DataBean.FtyListBean> resultList = new ArrayList<>();
                                for (int i = 0; i < list.size(); i++) {
                                    ChangeStorageManageBean.DataBean.FtyListBean factoryItem = list.get(i);
                                    if (factoryItem.getFty_code().contains(conditionStr) || factoryItem.getFty_name().contains(conditionStr)) {
                                        resultList.add(factoryItem);
                                    }
                                }
                                listview.setAdapter(new ChangeStorageFactoryListAdapter(context, resultList, adapterlistener));
                            }
                        });
                    } else {
                        condition.setVisibility(View.GONE);
                        search.setVisibility(View.GONE);
                    }
                }
        );
        return baseDialog;
    }

    //其他入库获取移动类型
    public static Dialog getMoveDialog(final Context context, final List<InStorageOtherIndexBean.OtherBean.MoveListBean> list, MoveListener listener) {
        BaseDialog baseDialog = BaseDialog.createDialog(context, R.layout.dialog_dispose_way, null, WindowManager.LayoutParams.WRAP_CONTENT, (Context con, View view, Dialog dialog) -> {
                    ListView disposeWayList = (ListView) view.findViewById(R.id.disposeWayList);
                    OtherMoveListAdapter adapter = new OtherMoveListAdapter(context, list, new OtherMoveListAdapter.MoveListAdapterListener() {
                        @Override
                        public void onSelect(String text, String specialInventory, String moveTypeDescription, String id, List<InStorageOtherIndexBean.OtherBean.MoveListBean.ReasonListBean> reasonList) {
                            dialog.cancel();
                            listener.onSelect(dialog, text, specialInventory, moveTypeDescription, id, reasonList);
                        }
                    });
                    disposeWayList.setAdapter(adapter);
                }
        );
        return baseDialog;
    }

    //其他出库获取移动类型
    public static Dialog getOutStorageMoveDialog(final Context context, final List<OutStorageOtherIndexBean.BodyBean.MoveListBean> list, MoveOutStorageListener listener) {
        BaseDialog baseDialog = BaseDialog.createDialog(context, R.layout.dialog_dispose_way, null, WindowManager.LayoutParams.WRAP_CONTENT, (Context con, View view, Dialog dialog) -> {
                    ListView disposeWayList = (ListView) view.findViewById(R.id.disposeWayList);
                    OtherOutStorageMoveListAdapter adapter = new OtherOutStorageMoveListAdapter(context, list, new OtherOutStorageMoveListAdapter.MoveListAdapterListener() {
                        @Override
                        public void onSelect(String id, String code, String name, String specialInventory) {
                            dialog.cancel();
                            listener.onSelect(dialog, id, code, name, specialInventory);
                        }
                    });
                    disposeWayList.setAdapter(adapter);
                }
        );
        return baseDialog;
    }

    //库存管理获取移动类型
    public static Dialog getChangeStorageMoveTypeDialog(final Context context, final List<ChangeStorageManageBean.DataBean.MoveListBean> list, ChangeStorageMoveTypeListener listener) {
        BaseDialog baseDialog = BaseDialog.createDialog(context, R.layout.dialog_dispose_way, null, WindowManager.LayoutParams.WRAP_CONTENT, (Context con, View view, Dialog dialog) -> {
            ListView disposeWayList = (ListView) view.findViewById(R.id.disposeWayList);
            ChangeMoveTypeListAdapter adapter = new ChangeMoveTypeListAdapter(context, list, new ChangeMoveTypeListAdapter.MoveTypeListAdapterListener() {
                @Override
                public void onSelect(String moveType, String moveTypeDescription, String move_id, String specialInventory, String businessType) {
                    dialog.cancel();
                    listener.onSelect(dialog, moveType, moveTypeDescription, move_id, specialInventory, businessType);

                }
            });
            disposeWayList.setAdapter(adapter);
        });
        return baseDialog;
    }

    //其他入库获取库存地点
    public static Dialog getInventoryAddressDialog(final Context context, final List<InStorageOtherIndexBean.OtherBean.FtyListBean.LocationAryBean> list, SelectListener listener) {
        BaseDialog baseDialog = BaseDialog.createDialog(context, R.layout.dialog_dispose_way, null, WindowManager.LayoutParams.WRAP_CONTENT, (Context con, View view, Dialog dialog) -> {
                    ListView disposeWayList = (ListView) view.findViewById(R.id.disposeWayList);
                    OtherInventoryAddressListAdapter adapter = new OtherInventoryAddressListAdapter(context, list, new OtherInventoryAddressListAdapter.InventoryAddressListAdapterListener() {
                        @Override
                        public void onSelect(String description, String value) {
                            dialog.cancel();
                            listener.onSelect(dialog, description, value);
                        }
                    });
                    disposeWayList.setAdapter(adapter);
                }
        );
        return baseDialog;
    }

    //其他出库获取库存地点
    public static Dialog getOutStorageInventoryAddressDialog(final Context context, final List<OutStorageOtherIndexBean.BodyBean.FtyListBean.LocationAryBean> list, SelectListener listener) {
        BaseDialog baseDialog = BaseDialog.createDialog(context, R.layout.dialog_dispose_way, null, WindowManager.LayoutParams.WRAP_CONTENT, (Context con, View view, Dialog dialog) -> {
                    ListView disposeWayList = (ListView) view.findViewById(R.id.disposeWayList);
                    OtherOutStorageInventoryAddressListAdapter adapter = new OtherOutStorageInventoryAddressListAdapter(context, list, new OtherOutStorageInventoryAddressListAdapter.InventoryAddressListAdapterListener() {
                        @Override
                        public void onSelect(String description, String value) {
                            dialog.cancel();
                            listener.onSelect(dialog, description, value);
                        }
                    });
                    disposeWayList.setAdapter(adapter);
                }
        );
        return baseDialog;
    }

    //其他出库获取接收方
    public static Dialog getOutStorageReceivingPartyDialog(final Context context, final List<OutStorageOtherIndexBean.BodyBean.ReceiverListBean> list, SelectListener listener) {
        BaseDialog baseDialog = BaseDialog.createDialog(context, R.layout.dialog_dispose_way, null, WindowManager.LayoutParams.WRAP_CONTENT, (Context con, View view, Dialog dialog) -> {
                    ListView disposeWayList = (ListView) view.findViewById(R.id.disposeWayList);
                    OtherOutStorageReceivingPartyListAdapter adapter = new OtherOutStorageReceivingPartyListAdapter(context, list, new OtherOutStorageReceivingPartyListAdapter.InventoryAddressListAdapterListener() {
                        @Override
                        public void onSelect(String description, String value) {
                            dialog.cancel();
                            listener.onSelect(dialog, description, value);
                        }
                    });
                    disposeWayList.setAdapter(adapter);
                }
        );
        return baseDialog;
    }

    //显示紧急出入库大图
    public static Dialog getEmergencyWarehousingBigPictureDialog(final Context context, String url, String path, boolean inlocal, DeleteListener listener) {
        WindowManager windowManager = (WindowManager) context
                .getSystemService(Context.WINDOW_SERVICE);
        Display display = windowManager.getDefaultDisplay();
        Point point = new Point();
        display.getSize(point);
        BaseDialog baseDialog = BaseDialog.createDialog(context, R.layout.view_emergency_warehousing_big_picture, null, (int) (point.y * 0.8), (Context con, View view, Dialog dialog) -> {
                    ImageView imageView = (ImageView) view.findViewById(R.id.bigImage);
                    if (inlocal) {
                        imageView.setImageBitmap(CameraUtils.uriToBitmap(path));
                        LogUtils.i("path1111 ==== " + path);
                    } else {
                        ImageManage.requestImage(context, imageView, url);
                        LogUtils.i("url1111 ==== " + url);
                    }
                    TextView back = (TextView) view.findViewById(R.id.back);
                    back.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            dialog.cancel();
                        }
                    });
                    ImageView deletePicture = (ImageView) view.findViewById(R.id.deletePicture);
                    deletePicture.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            listener.onDelect(dialog);
//                            dialog.cancel();
                        }
                    });

                }
        );
        return baseDialog;
    }

    //转储管理获取库存地点
    public static Dialog getChangeStorageInventoryAddressDialog(final Context context, final List<ChangeStorageManageBean.DataBean.FtyListBean.LocationAryBean> list, ChangeStorageInventoryAddressListener listener) {
        BaseDialog baseDialog = BaseDialog.createDialog(context, R.layout.dialog_dispose_way, null, WindowManager.LayoutParams.WRAP_CONTENT, (Context con, View view, Dialog dialog) -> {
                    ListView disposeWayList = (ListView) view.findViewById(R.id.disposeWayList);
                    ChangeStorageInventoryAddressListAdapter adapter = new ChangeStorageInventoryAddressListAdapter(context, list, new ChangeStorageInventoryAddressListAdapter.ChangeStorageInventoryAddressListAdapterListener() {
                        @Override
                        public void onSelect(String description, String value, String id, String warehouseNumber) {
                            dialog.cancel();
                            listener.onSelect(dialog, description, value, id, warehouseNumber);
                        }
                    });
                    disposeWayList.setAdapter(adapter);
                }
        );
        return baseDialog;
    }

    public static Dialog getInStorageReasonDialog(final Context context, final List<InStorageOtherIndexBean.OtherBean.MoveListBean.ReasonListBean> list, SelectListener listener) {
        BaseDialog baseDialog = BaseDialog.createDialog(context, R.layout.dialog_dispose_way, null, WindowManager.LayoutParams.WRAP_CONTENT, (Context con, View view, Dialog dialog) -> {
                    ListView disposeWayList = (ListView) view.findViewById(R.id.disposeWayList);
                    OtherInStorageReasonListAdapter adapter = new OtherInStorageReasonListAdapter(context, list, new OtherInStorageReasonListAdapter.InStorageReasonListAdapterListener() {
                        @Override
                        public void onSelect(String description, String value) {
                            dialog.cancel();
                            listener.onSelect(dialog, description, value);
                        }
                    });
                    disposeWayList.setAdapter(adapter);
                }
        );
        return baseDialog;
    }

    public static Dialog getPickingOutStorageNumberDialog(final Context context, String promptInfo, Double maxNumber, EditTextDialogListener listener) {
        BaseDialog baseDialog = BaseDialog.createDialog(context, R.layout.dialog_edittext, (Context con, View view, Dialog dialog) -> {
                    TextView prompt = (TextView) view.findViewById(R.id.prompt);
                    prompt.setText(promptInfo);
                    EditText number = (EditText) view.findViewById(R.id.number);
                    number.setRawInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
                    Button cancel = (Button) view.findViewById(R.id.cancel);
                    Button confirm = (Button) view.findViewById(R.id.confirm);
                    cancel.setOnClickListener(new NoDoubleClickListener() {
                        @Override
                        public void onNoDoubleClick(View v) {
                            dialog.cancel();
                        }
                    });
                    confirm.setOnClickListener(new NoDoubleClickListener() {
                        @Override
                        public void onNoDoubleClick(View v) {
                            if (TextUtils.isEmpty(number.getText().toString())) {
                                Utils.middleToast(context, "数量不能为空");
                            } else {
                                Double numberDou = Double.parseDouble(number.getText().toString());
                                if (numberDou > maxNumber) {
                                    Utils.middleToast(context, "输入数量必须小于实发数量(" + maxNumber + ")");
                                } else {
                                    listener.onConfirm(dialog, number.getText().toString());
                                }
                            }
                        }
                    });
                }
        );
        baseDialog.setCancelable(false);
        return baseDialog;
    }

    public static Dialog getAddBatchDialog(final Context context, final List<OutStoragePickingBatchListBean.DataBean.BatchListBean> list, AddBatchListener listener) {
        WindowManager windowManager = (WindowManager) context
                .getSystemService(Context.WINDOW_SERVICE);
        Display display = windowManager.getDefaultDisplay();
        Point point = new Point();
        display.getSize(point);
        BaseDialog baseDialog = BaseDialog.createDialog(context, R.layout.dialog_add_batch, (int) (point.x * 0.9), (int) (point.y * 0.6), (Context con, View view, Dialog dialog) -> {
                    ListView batchList = (ListView) view.findViewById(R.id.batchList);
                    PickingOutStorageAddBatchAdapter adapter = new PickingOutStorageAddBatchAdapter(context, list, new PickingOutStorageAddBatchAdapter.PickingOutStorageAddBatchAdapterListener() {
                        @Override
                        public void onSelect(OutStoragePickingBatchListBean.DataBean.BatchListBean item) {
                            dialog.cancel();
                            listener.onSelect(dialog, item);
                        }
                    });
                    batchList.setAdapter(adapter);
                }
        );
        return baseDialog;
    }

    public static Dialog getAddBatchDialogNew(final Context context, final List<BatchBean.BatchInfoBean> list, AddBatchListenerNew listener) {
        WindowManager windowManager = (WindowManager) context
                .getSystemService(Context.WINDOW_SERVICE);
        Display display = windowManager.getDefaultDisplay();
        Point point = new Point();
        display.getSize(point);
        BaseDialog baseDialog = BaseDialog.createDialog(context, R.layout.dialog_add_batch, (int) (point.x * 0.9), (int) (point.y * 0.6), (Context con, View view, Dialog dialog) -> {
                    ListView batchList = (ListView) view.findViewById(R.id.batchList);
                    OutStorageAddBatchAdapter adapter = new OutStorageAddBatchAdapter(context, list, new OutStorageAddBatchListener() {
                        @Override
                        public void onSelect(BatchBean.BatchInfoBean item) {
                            dialog.cancel();
                            listener.onSelect(dialog, item);
                        }
                    });
                    batchList.setAdapter(adapter);
                }
        );
        return baseDialog;
    }

    public static Dialog getLoadingDialog(final Context context, LoadingListener listener, String... message) {
        Dialog result = LoadingDialog.createDialog(context, message.length <= 0 ? "" : message[0]);
        result.setOnCancelListener((DialogInterface dialog) -> {
            if (listener != null) {
                listener.onCancel();
            }
        });
        return result;
    }

    //库存查询选择仓库号
    public static Dialog getWarehouseDialog(final Context context, final List<QueryWarehouseBean.DataBean.WarehouseListBean> list, WarehouseListener listener) {
        BaseDialog baseDialog = BaseDialog.createDialog(context, R.layout.dialog_dispose_way, null, WindowManager.LayoutParams.WRAP_CONTENT, (Context con, View view, Dialog dialog) -> {
                    ListView disposeWayList = (ListView) view.findViewById(R.id.disposeWayList);
                    QueryWarehouseListAdapter adapter = new QueryWarehouseListAdapter(context, list, new QueryWarehouseListAdapter.QueryWarehouseListAdapterListener() {
                        @Override
                        public void onSelect(String warehouseNumber, String warehouseDescription, List<QueryWarehouseBean.DataBean.WarehouseListBean.AreaListBean> areaList) {
                            dialog.cancel();
                            listener.onSelect(dialog, warehouseNumber, warehouseDescription, areaList);
                        }
                    });
                    disposeWayList.setAdapter(adapter);
                }
        );
        return baseDialog;
    }

    //库存查询选择存储区
    public static Dialog getAreaDialog(final Context context, final List<QueryWarehouseBean.DataBean.WarehouseListBean.AreaListBean> list, AreaListener listener) {
        BaseDialog baseDialog = BaseDialog.createDialog(context, R.layout.dialog_dispose_way, null, WindowManager.LayoutParams.WRAP_CONTENT, (Context con, View view, Dialog dialog) -> {
                    ListView disposeWayList = (ListView) view.findViewById(R.id.disposeWayList);
                    QueryAreaListAdapter adapter = new QueryAreaListAdapter(context, list, new QueryAreaListAdapter.QueryAreaListAdapterListener() {
                        @Override
                        public void onSelect(String areaNumber, String areaDescription) {
                            dialog.cancel();
                            listener.onSelect(dialog, areaNumber, areaDescription);
                        }
                    });
                    disposeWayList.setAdapter(adapter);
                }
        );
        return baseDialog;
    }

    //库存查询选择批次
    public static Dialog getBatchNumberDialog(final Context context, final List<QueryMaterielDetailBean.DataBean.BatchListBean> list, BatchNumberListener listener) {
        BaseDialog baseDialog = BaseDialog.createDialog(context, R.layout.dialog_dispose_way, null, WindowManager.LayoutParams.WRAP_CONTENT, (Context con, View view, Dialog dialog) -> {
                    ListView disposeWayList = (ListView) view.findViewById(R.id.disposeWayList);
                    QueryBatchNumberListAdapter adapter = new QueryBatchNumberListAdapter(context, list, new QueryBatchNumberListAdapter.QueryBatchNumberListAdapterListener() {
                        @Override
                        public void onSelect(QueryMaterielDetailBean.DataBean.BatchListBean batchItem) {
                            dialog.cancel();
                            listener.onSelect(dialog, batchItem);
                        }
                    });
                    disposeWayList.setAdapter(adapter);
                }
        );
        return baseDialog;
    }

    //查询出库获取库存地点
    public static Dialog getQueryOutStorageDialog(final Context context, final List<QueryOutStorageInventoryAddressBean.DataBean.InventoryAddressListBean> list, QueryOutStorageListener listener) {
        BaseDialog baseDialog = BaseDialog.createDialog(context, R.layout.dialog_dispose_way, null, WindowManager.LayoutParams.WRAP_CONTENT, (Context con, View view, Dialog dialog) -> {
                    ListView disposeWayList = (ListView) view.findViewById(R.id.disposeWayList);
                    QueryOutStorageInventoryAddressListAdapter adapter = new QueryOutStorageInventoryAddressListAdapter(context, list, new QueryOutStorageInventoryAddressListAdapter.QueryOutStorageInventoryAddressListAdapterListener() {
                        @Override
                        public void onSelect(String description, String value) {
                            dialog.cancel();
                            listener.onSelect(dialog, description, value);
                        }
                    });
                    disposeWayList.setAdapter(adapter);
                }
        );
        return baseDialog;
    }

    public static Dialog getOverviewDialog(final Context context, final List<OverviewAdapter.OverviewBean> overViewlist) {
        WindowManager windowManager = (WindowManager) context
                .getSystemService(Context.WINDOW_SERVICE);
        Display display = windowManager.getDefaultDisplay();
        Point point = new Point();
        display.getSize(point);
        BaseDialog baseDialog = BaseDialog.createDialog(context, R.layout.dialog_add_batch, (int) (point.x * 0.9), WindowManager.LayoutParams.WRAP_CONTENT, (Context con, View view, Dialog dialog) -> {
                    ListView batchList = (ListView) view.findViewById(R.id.batchList);
                    OverviewAdapter adapter = new OverviewAdapter(context, overViewlist);
                    batchList.setAdapter(adapter);
                }
        );
        return baseDialog;
    }

    //验收入库获取角色
    public static Dialog getRoleaDialog(final Context context, final List<InStorageRoleBean.DataBean.RoleListBean> list, RoleListener listener) {
//        BaseDialog baseDialog = BaseDialog.createDialog(context, R.layout.dialog_dispose_way, null, WindowManager.LayoutParams.WRAP_CONTENT, (Context con, View view, Dialog dialog) -> {
//                    ListView disposeWayList = (ListView) view.findViewById(R.id.disposeWayList);
//                    RoleListAdapter adapter = new RoleListAdapter(context, list, new RoleListAdapter.RoleListAdapterListener() {
//                        @Override
//                        public void onSelect(String roleName, String roleCode) {
//                            dialog.cancel();
//                            listener.onSelect(dialog, roleName, roleCode);
//                        }
//                    });
//                    disposeWayList.setAdapter(adapter);
//                }
//        );
//        return baseDialog;
        return null;
    }

    //验收入库获取角色
    public static Dialog getRoleaDialogNew(final Context context, final List<GetRoleBean.RoleBean> list, RoleListener listener) {
        BaseDialog baseDialog = BaseDialog.createDialog(context, R.layout.dialog_dispose_way, null, WindowManager.LayoutParams.WRAP_CONTENT, (Context con, View view, Dialog dialog) -> {
                    ListView disposeWayList = (ListView) view.findViewById(R.id.disposeWayList);
                    RoleListAdapter adapter = new RoleListAdapter(context, list, new RoleListAdapter.RoleListAdapterListener() {
                        @Override
                        public void onSelect(String roleName, String roleCode) {
                            dialog.cancel();
                            listener.onSelect(dialog, roleName, roleCode);
                        }
                    });
                    disposeWayList.setAdapter(adapter);
                }
        );
        return baseDialog;
    }

    //验收入库获取用户组
    public static Dialog getUserGroupDialog(final Context context, final List<InStorageReceiveAddOperatorUserGroupBean.DataBean.GroupListBean> list, RoleListener listener) {
//        BaseDialog baseDialog = BaseDialog.createDialog(context, R.layout.dialog_dispose_way, null, WindowManager.LayoutParams.WRAP_CONTENT, (Context con, View view, Dialog dialog) -> {
//                    ListView disposeWayList = (ListView) view.findViewById(R.id.disposeWayList);
//                    UserGroupListAdapter adapter = new UserGroupListAdapter(context, list, new UserGroupListAdapter.GroupListAdapterListener() {
//                        @Override
//                        public void onSelect(String groupoName, String groupCode) {
//                            dialog.cancel();
//                            listener.onSelect(dialog, groupoName, groupCode);
//                        }
//                    });
//                    disposeWayList.setAdapter(adapter);
//                }
//        );
//        return baseDialog;
        return null;
    }

    //验收入库获取用户组
    public static Dialog getUserGroupDialogNew(final Context context, final List<GetOperatorGroupBean.OperatorGroupBean> list, RoleListener listener) {
        BaseDialog baseDialog = BaseDialog.createDialog(context, R.layout.dialog_dispose_way, null, WindowManager.LayoutParams.WRAP_CONTENT, (Context con, View view, Dialog dialog) -> {
                    ListView disposeWayList = (ListView) view.findViewById(R.id.disposeWayList);
                    UserGroupListAdapter adapter = new UserGroupListAdapter(context, list, new GetOperatorGroupListener() {
                        @Override
                        public void onSelect(String groupoName, String groupCode) {
                            dialog.cancel();
                            listener.onSelect(dialog, groupoName, groupCode);
                        }
                    });
                    disposeWayList.setAdapter(adapter);
                }
        );
        return baseDialog;
    }

    //领料退库获取用户组
    public static Dialog getRefundStorageUserGroupDialog(final Context context, final List<GetOperatorGroupBean.OperatorGroupBean> list, RoleListener listener) {
        BaseDialog baseDialog = BaseDialog.createDialog(context, R.layout.dialog_dispose_way, null, WindowManager.LayoutParams.WRAP_CONTENT, (Context con, View view, Dialog dialog) -> {
                    ListView disposeWayList = (ListView) view.findViewById(R.id.disposeWayList);
                    RefundStoragePickingUserGroupListAdapter adapter = new RefundStoragePickingUserGroupListAdapter(context, list, new RefundStoragePickingUserGroupListAdapter.GroupListAdapterListener() {
                        @Override
                        public void onSelect(String groupoName, String groupCode) {
                            dialog.cancel();
                            listener.onSelect(dialog, groupoName, groupCode);
                        }
                    });
                    disposeWayList.setAdapter(adapter);
                }
        );
        return baseDialog;
    }

    //领料退库获取角色
    public static Dialog getRefundStoragePickingRoleDialog(final Context context, final List<GetRoleBean.RoleBean> list, RoleListener listener) {
        BaseDialog baseDialog = BaseDialog.createDialog(context, R.layout.dialog_dispose_way, null, WindowManager.LayoutParams.WRAP_CONTENT, (Context con, View view, Dialog dialog) -> {
                    ListView disposeWayList = (ListView) view.findViewById(R.id.disposeWayList);
                    RefundStoragePickingRoleListAdapter adapter = new RefundStoragePickingRoleListAdapter(context, list, new RefundStoragePickingRoleListAdapter.RoleListAdapterListener() {
                        @Override
                        public void onSelect(String roleName, String roleCode) {
                            dialog.cancel();
                            listener.onSelect(dialog, roleName, roleCode);
                        }
                    });
                    disposeWayList.setAdapter(adapter);
                }
        );
        return baseDialog;
    }

    //领料退库获取批次
    public static Dialog getRefundStoragePickingBatchDialog(final Context context, final List<RefundStoragePickingOverviewBean.OutputInfoBodyBean.ItemListBean.BatchListBean> list, RefundStoragePickingBatchNumberListener listener) {
        BaseDialog baseDialog = BaseDialog.createDialog(context, R.layout.dialog_dispose_way, null, WindowManager.LayoutParams.WRAP_CONTENT, (Context con, View view, Dialog dialog) -> {
                    ListView disposeWayList = (ListView) view.findViewById(R.id.disposeWayList);
                    RefundStoragePickingBatchListAdapter adapter = new RefundStoragePickingBatchListAdapter(context, list, new RefundStoragePickingBatchListAdapter.BatchListAdapterListener() {
                        @Override
                        public void onSelect(String batchNumber, List<RefundStoragePickingOverviewBean.OutputInfoBodyBean.ItemListBean.BatchListBean.BatchSpecListBean> batchInfoList) {
                            dialog.cancel();
                            listener.onSelect(dialog, batchNumber, batchInfoList);
                        }
                    });
                    disposeWayList.setAdapter(adapter);
                }
        );
        return baseDialog;
    }

    //销售退库获取批次
    public static Dialog getRefundStorageSaleBatchDialog(final Context context, final List<RefundStorageSaleBatchListBean.SaleBatchBodyBean> list, RefundStorageSaleBatchNumberListener listener) {
        BaseDialog baseDialog = BaseDialog.createDialog(context, R.layout.dialog_choose_batch, null, WindowManager.LayoutParams.WRAP_CONTENT, (Context con, View view, Dialog dialog) -> {
                    TextView newBath = (TextView) view.findViewById(R.id.newBath);
                    newBath.setOnClickListener(new NoDoubleClickListener() {
                        @Override
                        public void onNoDoubleClick(View v) {
                            dialog.cancel();
                            listener.onNewBatch();
                        }
                    });
                    ListView disposeWayList = (ListView) view.findViewById(R.id.disposeWayList);
                    RefundStorageSaleBatchListAdapter adapter = new RefundStorageSaleBatchListAdapter(context, list, new RefundStorageSaleBatchListAdapter.BatchListAdapterListener() {
                        @Override
                        public void onSelect(String batchNumber, List<RefundStorageSaleBatchListBean.SaleBatchBodyBean.BatchSpecListBean> batchInfoList) {
                            dialog.cancel();
                            listener.onSelect(dialog, batchNumber, batchInfoList);
                        }
                    });
                    disposeWayList.setAdapter(adapter);
                }
        );
        return baseDialog;
    }

    //新建批次dialog
    public static Dialog getNewBatchDialog(final Context context, List<BatchSpecListBean> list, String serial, RefundStorageSaleNewBatchNumberListener listener) {
        BaseDialog baseDialog = BaseDialog.createDialog(context, R.layout.dialog_new_batch, null, WindowManager.LayoutParams.WRAP_CONTENT, (Context con, View view, Dialog dialog) -> {
                    PercentLinearLayout batch = (PercentLinearLayout) view.findViewById(R.id.batchLayout);
                    Button save = (Button) view.findViewById(R.id.save);
                    Button cancel = (Button) view.findViewById(R.id.cancel);

                    for (int i = 0; i < list.size(); i++) {
                        BatchSpecListBean batchItem = list.get(i);
                        String type = batchItem.getBatch_spec_type();
                        boolean required = "1".equals(batchItem.getRequired()) ? true : false;
                        switch (type) {
                            case "1":
                                InStorageUtils.createEditText(context, batch, batchItem.getBatch_spec_name(), required, batchItem.getText(), batchItem.getBatch_spec_value(), i + 1);
                                break;
                            case "2":
                                InStorageUtils.createDatePicker((BaseActivity) context, batch, batchItem.getBatch_spec_name(), required, batchItem.getText(), batchItem.getBatch_spec_value(), i + 1);
                                break;
                            case "3":
                                RefundStorageUtils.createNewBatchSelect(context, batch, batchItem.getBatch_spec_name(), required, batchItem.getText(), batchItem.getBatch_spec_value(), batchItem.getInfo(), i + 1);
                                break;
                        }
                    }
                    cancel.setOnClickListener(new NoDoubleClickListener() {
                        @Override
                        public void onNoDoubleClick(View v) {
                            dialog.cancel();
                        }
                    });
                    save.setOnClickListener(new NoDoubleClickListener() {
                        @Override
                        public void onNoDoubleClick(View v) {
                            String checkResult = RefundStorageUtils.newBatchCheck(context, list, view);
                            if (checkResult == null) {
                                dialog.cancel();
                                listener.onNewBatch(RefundStorageUtils.updateNewBatchInfo(context, view, serial, list));
                                Utils.closeSoftKeyboard(context, view);

                            } else {
                                DialogUtils.getConfirmDialog(context, checkResult + "\n" + context.getResources().getString(R.string.activity_in_storage_receive_materiel_detail_force_exit), new DialogUtils.ConfirmDialogListener() {
                                    @Override
                                    public void onConfirm(Dialog dialog1) {
                                        dialog.cancel();
                                    }
                                }).show();
                            }
                        }
                    });

                }
        );
        return baseDialog;
    }

    //工作量统计分析获取板块
    public static Dialog getWorkStatisticsBlockDialog(final Context context, final List<AnalysisWorkStatisticsIndexBean.DataBean.BlockListBean> list, AnalysisWorkStatisticsListener listener) {
        BaseDialog baseDialog = BaseDialog.createDialog(context, R.layout.dialog_dispose_way, null, WindowManager.LayoutParams.WRAP_CONTENT, (Context con, View view, Dialog dialog) -> {
                    ListView disposeWayList = (ListView) view.findViewById(R.id.disposeWayList);
                    WorkStatisticsBlockListAdapter adapter = new WorkStatisticsBlockListAdapter(context, list, new WorkStatisticsBlockListAdapter.WorkStatisticsBlockListAdapterListener() {
                        @Override
                        public void onSelect(String description, String value) {
                            dialog.cancel();
                            listener.onSelect(dialog, description, value);
                        }
                    });
                    disposeWayList.setAdapter(adapter);
                }
        );
        return baseDialog;
    }

    //工作量统计分析获取工厂
    public static Dialog getWorkStatisticsFactoryDialog(final Context context, final List<AnalysisWorkStatisticsIndexBean.DataBean.BlockListBean.FactoryListBean> list, AnalysisWorkStatisticsListener listener) {
        BaseDialog baseDialog = BaseDialog.createDialog(context, R.layout.dialog_dispose_way, null, WindowManager.LayoutParams.WRAP_CONTENT, (Context con, View view, Dialog dialog) -> {
                    ListView disposeWayList = (ListView) view.findViewById(R.id.disposeWayList);
                    WorkStatisticsFactoryListAdapter adapter = new WorkStatisticsFactoryListAdapter(context, list, new WorkStatisticsFactoryListAdapter.WorkStatisticsFactoryListAdapterListener() {
                        @Override
                        public void onSelect(String description, String value) {
                            dialog.cancel();
                            listener.onSelect(dialog, description, value);
                        }
                    });
                    disposeWayList.setAdapter(adapter);
                }
        );
        return baseDialog;
    }

    //工作量统计分析获取库存地点
    public static Dialog getWorkStatisticsInventoryAddressDialog(final Context context, final List<AnalysisWorkStatisticsIndexBean.DataBean.BlockListBean.FactoryListBean.InventoryAddressListBean> list, AnalysisWorkStatisticsListener listener) {
        BaseDialog baseDialog = BaseDialog.createDialog(context, R.layout.dialog_dispose_way, null, WindowManager.LayoutParams.WRAP_CONTENT, (Context con, View view, Dialog dialog) -> {
                    ListView disposeWayList = (ListView) view.findViewById(R.id.disposeWayList);
                    WorkStatisticsInventoryAddressListAdapter adapter = new WorkStatisticsInventoryAddressListAdapter(context, list, new WorkStatisticsInventoryAddressListAdapter.WorkStatisticsInventoryAddressListAdapterListener() {
                        @Override
                        public void onSelect(String description, String value) {
                            dialog.cancel();
                            listener.onSelect(dialog, description, value);
                        }
                    });
                    disposeWayList.setAdapter(adapter);
                }
        );
        return baseDialog;
    }

    //工作量统计分析获取库人员
    public static Dialog getWorkStatisticsPersonDialog(final Context context, final List<AnalysisWorkStatisticsGetPersonBean.DataBean.PersonListBean> list, AnalysisWorkStatisticsListener listener) {
        BaseDialog baseDialog = BaseDialog.createDialog(context, R.layout.dialog_dispose_way, null, WindowManager.LayoutParams.WRAP_CONTENT, (Context con, View view, Dialog dialog) -> {
                    ListView disposeWayList = (ListView) view.findViewById(R.id.disposeWayList);
                    WorkStatisticsPersonListAdapter adapter = new WorkStatisticsPersonListAdapter(context, list, new WorkStatisticsPersonListAdapter.WorkStatisticsPersonListAdapterListener() {
                        @Override
                        public void onSelect(String description, String value) {
                            dialog.cancel();
                            listener.onSelect(dialog, description, value);
                        }
                    });
                    disposeWayList.setAdapter(adapter);
                }
        );
        return baseDialog;
    }

    //仓库整理基于仓位整理获取仓位
    public static Dialog getStoragePositionDialog(final Context context, final List<StorageManagePosiBean.BodyBean> list, StoragePositionListener listener) {
        BaseDialog baseDialog = BaseDialog.createDialog(context, R.layout.dialog_dispose_way, null, WindowManager.LayoutParams.WRAP_CONTENT, (Context con, View view, Dialog dialog) -> {
                    ListView disposeWayList = (ListView) view.findViewById(R.id.disposeWayList);
                    StoragePositionListAdapter adapter = new StoragePositionListAdapter(context, list, new StoragePositionListAdapter.StoragePositionListener() {
                        @Override
                        public void onSelect(String id, String code, String name, String factoryId, String inventoryAddressId) {
                            dialog.cancel();
                            listener.onSelect(dialog, id, code, name, factoryId, inventoryAddressId);
                        }
                    });
                    disposeWayList.setAdapter(adapter);
                }
        );
        return baseDialog;
    }

    //仓库整理基于物料整理获取工厂
    public static Dialog getStorageMaterielFactoryDialog(final Context context, final List<StorageManageMaterielIndexBean.BodyBean> list, StorageMaterielFactoryListener listener) {
        BaseDialog baseDialog = BaseDialog.createDialog(context, R.layout.dialog_dispose_way, null, WindowManager.LayoutParams.WRAP_CONTENT, (Context con, View view, Dialog dialog) -> {
                    ListView disposeWayList = (ListView) view.findViewById(R.id.disposeWayList);
                    StorageMaterielFactoryListAdapter adapter = new StorageMaterielFactoryListAdapter(context, list, new StorageMaterielFactoryListAdapter.FactoryListAdapterListener() {
                        @Override
                        public void onSelect(String id, String code, String name, List<StorageManageMaterielIndexBean.BodyBean.LocationAryBean> inventoryAddressList) {
                            dialog.cancel();
                            listener.onSelect(dialog, id, code, name, inventoryAddressList);
                        }
                    });
                    disposeWayList.setAdapter(adapter);
                }
        );
        return baseDialog;
    }

    //仓库整理基于物料整理获取库存地点
    public static Dialog getStorageMaterielInventoryAddressDialog(final Context context, final List<StorageManageMaterielIndexBean.BodyBean.LocationAryBean> list, StorageMaterielInventoryAddressListener listener) {
        BaseDialog baseDialog = BaseDialog.createDialog(context, R.layout.dialog_dispose_way, null, WindowManager.LayoutParams.WRAP_CONTENT, (Context con, View view, Dialog dialog) -> {
                    ListView disposeWayList = (ListView) view.findViewById(R.id.disposeWayList);
                    StorageMaterielInventoryAddressListAdapter adapter = new StorageMaterielInventoryAddressListAdapter(context, list, new StorageMaterielInventoryAddressListAdapter.InventoryAddressListAdapterListener() {
                        @Override
                        public void onSelect(String inventoryAddressId, String inventoryAddressCode, String inventoryAddressName, String warehouseId) {
                            dialog.cancel();
                            listener.onSelect(dialog, inventoryAddressId, inventoryAddressCode, inventoryAddressName, warehouseId);
                        }
                    });
                    disposeWayList.setAdapter(adapter);
                }
        );
        return baseDialog;
    }
    //转储获取库存地点
    public static Dialog getCYChangeStorageLocationDialog(final Context context, final List<CYChangeStorageLocationBean.LocationBean.LocationAryBean> list, CYChangStorageSelectLocationListener listener) {
        BaseDialog baseDialog = BaseDialog.createDialog(context, R.layout.dialog_dispose_way, null, WindowManager.LayoutParams.WRAP_CONTENT, (Context con, View view, Dialog dialog) -> {
                    ListView disposeWayList = (ListView) view.findViewById(R.id.disposeWayList);
            CYChangeStorageLocationListAdapter adapter = new CYChangeStorageLocationListAdapter(context, list, new CYChangeStorageLocationListAdapter.CYChangeStorageLocationListAdapterListener() {
                        @Override
                        public void onSelect(String code, String name , String id) {
                            dialog.cancel();
                            listener.onSelect(dialog, code, name , id);
                        }
                    });
                    disposeWayList.setAdapter(adapter);
                }
        );
        return baseDialog;
    }

    public static Dialog getAllocationCreatDocumentFtyDialog(Context context, List<AllocationOutStorageBaseInfoBean.BaseInfoBodyBean.FtyListBean.LocationAryBean> list, AllocationCreatDocumentFtyListener listener) {
        BaseDialog baseDialog = BaseDialog.createDialog(context, R.layout.dialog_dispose_way, null, WindowManager.LayoutParams.WRAP_CONTENT, (Context con, View view, Dialog dialog) -> {
                    ListView disposeWayList = (ListView) view.findViewById(R.id.disposeWayList);
                    AllocationCreatDocumentFtyAdapter adapter = new AllocationCreatDocumentFtyAdapter(context, list, new AllocationCreatDocumentFtyAdapter.InventoryAddressListAdapterListener() {
                        @Override
                        public void onSelect(String id, String code, String name) {
                            dialog.cancel();
                            listener.onSelect(dialog, id, code, name);
                        }
                    });
                    disposeWayList.setAdapter(adapter);
                }
        );
        return baseDialog;
    }
}
